<!--
 * @Author: hua
 * @Date: 2020-07-21 14:20:36
 * @description: 
 * @LastEditors: hua
 * @LastEditTime: 2020-09-30 15:37:25
--> 
<template>
  <div class="container">
    <HeaderBindEquipment />
    <div style="padding:5px;display:flex;flex-direction:row;width:100%;height:55px;line-height:35px;text-align:center">
      <div style="flex:1;border-bottom:3px solid #4E9AFF;"> <div class="badge_wrapper">1</div><span style="color:#4E9AFF" >选择生产批次</span></div>
      <div style="flex:1;border-bottom:3px solid #EAEAEA;"> <div class="badge_default_wrapper">2</div>绑定设备</div>
    </div>
   
    <div style="display:flex;flex-direction:row;flex-wrap:wrap;margin-top:20px">
      <el-card
        v-for="(item,index) in tableData"
        :key="index"
        class="box-card"
        style="border-radius:10px;width:28%;margin-right:3.33%;margin-bottom:20px;border: 2px solid #4E9AFF;box-shadow: 0px 3px 15px rgba(78, 154, 255, 0.3);"
        @click.native="handleSaveProductionBatch(item)"
      >
        <div slot="header" class="card_header">
          <img style="margin-left:16px;margin-top:6px;" :src="require('@/assets/batch.svg')"/>
        </div>
        <div class="text item">
          <span class="item_name">{{$t('batchName')}}：</span>
          {{item.batchName}}
        </div>
        <div class="text item">
          <span class="item_name">{{$t('batchNumber')}}：</span>
          {{item.batchNumber}}
        </div>
        <div class="text item">
          <span class="item_name">{{$t('startDate')}}：</span>
          {{item.startDate}}
        </div>
        <div class="text item">
          <span class="item_name">{{$t('endDate')}}：</span>
          {{item.endDate}}
        </div>
      </el-card>
    </div>

    <!-- <el-table :data="tableData" style="width: 100%">
      <el-table-column prop="batchName" :label="$t('batchName')" width="180"></el-table-column>
      <el-table-column prop="batchNumber" :label="$t('batchNumber')" width="180"></el-table-column>
      <el-table-column prop="startDate" :label="$t('startDate')"></el-table-column>
      <el-table-column prop="endDate" :label="$t('endDate')"></el-table-column>
      <el-table-column :label="$t('action')" :align="'center'">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="primary"
            @click="handleSaveProductionBatch(scope.row)"
          >{{$t('choose')}}</el-button>
        </template>
      </el-table-column>
    </el-table>-->
  </div>
</template>

<script>
import { mapGetters } from "vuex";
import { Message } from "element-ui";
import HeaderBindEquipment from "@/components/HeaderBindEquipment/index";
import { getProductionBatch } from "@/api/lock";
import { setProductionBatch } from "@/utils/auth";
export default {
  name: "chooseProductionPlan",
  data() {
    return {
      productionBatch: {
        creationDate: "",
        lastModifiedDate: null,
        id: 0,
        batchName: "",
        batchNumber: "",
        startDate: "",
        endDate: "",
        enable: 0,
      },
      tableData: [],
    };
  },
  components: { HeaderBindEquipment },
  computed: {
    ...mapGetters(["userInfo"]),
  },
  created() {
    getProductionBatch().then((res) => {
      this.tableData = res.body;
      console.log(res.body);
    });
  },
  methods: {
    handleSaveProductionBatch(row) {
      this.$store.commit("SAVE_PRODUCTION_BARCH", row);
      setProductionBatch(row);
      /* Message({
        message: `${
          this.$t("ChooseProductionPlan") + " " + this.$t("success")
        }`,
        type: "success",
        duration: 5 * 1000,
      }); */
      this.$router.push({ name: "behindCode" });
    },
  },
};
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.container {
  padding: 10px 20px 10px 20px;
  overflow: auto;
  height: 100%;
}
.box-card {
  cursor: pointer;
}
.item {
  
  font-size: 14px;
  font-family: Helvetica Neue;
  font-weight: bold;
  line-height: 40px;
  color: #333333;
  opacity: 1;
}
.badge_wrapper{
  width: 24px;
  height: 24px;
  background: linear-gradient(138deg, #4E9AFF 0%, #1172F2 100%);
  box-shadow: 0px 3px 6px rgba(78, 154, 255, 0.3);
  border-radius: 50%;
  text-align: center;
  font-size: 14px;
  font-family: Helvetica Neue;
  font-weight: 500;
  line-height: 24px;
  color: #FFFFFF;
  opacity: 1;
  display:inline-block;
  margin-right:10px;
}
.badge_default_wrapper{
  width: 24px;
  height: 24px;
  background: rgba(51, 51, 51, 0.1);
  border-radius: 50%;
  font-size: 14px;
  font-family: Helvetica Neue;
  font-weight: 500;
  line-height:  24px;
  color: rgba(51, 51, 51, 0.4);
  text-align: center;
  display:inline-block;
  margin-right:10px;
}
.card_header{
  height: 45px!important;
  background: #4E9AFF!important;
}
.item_name{ 
  font-size: 14px;
  font-family: Helvetica Neue;
  font-weight: 400;
  line-height: 40px;
  color: #333333;
  opacity: 1;
  margin-right:30px;
}
</style>
